package util;

import java.util.ArrayList;

public class StringUtil {
	public static  ArrayList<String> lexicalAnalyze(String longsrt) {
		ArrayList<String> words = new ArrayList<String>();
		String[] tokens = longsrt.split("[\\W]");
		for (String word : tokens) {
			words.add(word.trim());
		}
		return words;
	}

	public static ArrayList<Integer[]> ConvertToIntegerList(ArrayList<String> inputList) {
		ArrayList<Integer[]> retunrList = new ArrayList<Integer[]>();
		for(String str : inputList){
			String[] numStrs = str.split("[\\s]");
			Integer[] nums = new Integer[numStrs.length];
			for(int i = 0; i < numStrs.length; i++){
				nums[i] = Integer.parseInt(numStrs[i]);
			}
			retunrList.add(nums);
		}
		return retunrList;
	}
	
	public static String listToString(ArrayList<String> list) {
		String str = "";
		for (String word : list) {
			str += word + " ";
		}
		try {
			if (str.length() != 0)
				str = str.substring(0, str.length() - 1);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return str;
	}

	public static void main(String[] args) {
		String[] str = "asass'asasa 'asasas".split("[\\W]");
		System.out.println(str);
	}
}
